﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

namespace NLE
{
    public partial class Options : Form
    {
        public MainForm mainForm { get; set; }

        public Options()
        {
            InitializeComponent();


        }

        string _tempGamePath = String.Empty;
        string _tempGameArgs = String.Empty;


        public void InitPath() {
            txtPath.Text = mainForm.GamePath + " " + mainForm.GameArgs;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnLocateGame_Click(object sender, EventArgs e)
        {
            if ( String.IsNullOrEmpty(mainForm.SavePath) ) {

                MessageBox.Show("Please save your level first.");

            }
            else {

                OpenFileDialog fileDialog = new OpenFileDialog();

                fileDialog.Title = "Locate game executable...";

                fileDialog.Filter = "EXE Files (*.exe)|*.exe|" +
                                    "All Files (*.*)|*.*";

                if (fileDialog.ShowDialog() == DialogResult.OK)
                {

                    lblConf.Enabled = true;
                    _tempGamePath = fileDialog.FileName;
                    _tempGameArgs = "-loadlevel \""+mainForm.SavePath+"\"";

                    txtPath.Text = _tempGamePath + " " + _tempGameArgs;


                }
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            mainForm.GamePath = _tempGamePath;
            mainForm.GameArgs = _tempGameArgs;
            Close();
        }




    }
}
